<?php

namespace co2_OS\apps\explain\dev\v0_0_0;

use co2_OS as kernel;
use co2\dev\v0_0_0 as api;

class status

{
  protected
    $explanation
    ;
    
  public function __construct
  (
  	$status
  )
  {
    if(!is_numeric($status))
    throw new api\Exception('Status must be a number');
  
    $r=new \ReflectionClass('co2_OS\\EXIT_STATUS');
    
    $constants=$r->getConstants();
    
    foreach($constants as $k=>$v)
    if($v==(int)$status)
    $this->explanation=$k;
  }
  
  public function
  __invoke()
  
  {
    return $this->explanation;
  }
  
  public function
  __toString()
  
  {
    if(is_null($this->explanation))
    return 'status not found';
    
    return $this->explanation;
  }
}
